//
//  DetailHeaderView.m
//  Grammar
//
//  Created by Rick on 6/29/13.
//
//

#import "DetailHeaderView.h"

@implementation DetailHeaderView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)awakeFromNib
{
    [super awakeFromNib];
    UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapOnHeaderView)];
    [self addGestureRecognizer:tapGestureRecognizer];
    [tapGestureRecognizer release];
    [self performSelector:@selector(tapOnHeaderView)];
}
- (void)setSection:(NSInteger)section
{
    _section = section;
}
- (void)tapOnHeaderView
{
    if (_delegate && [_delegate respondsToSelector:@selector(headerViewDidTapAtIndex:)])
    {
        [_delegate headerViewDidTapAtIndex:_section];
    }
}

- (void)setViewWithGrammarExplain:(GrammarExplain*)explain
{
    _titleLabel.text = explain.title;
    
    NSDate * updateDate = [NSDate dateWithTimeIntervalSince1970:[[explain.lastUpdateTimeStamp substringToIndex:explain.lastUpdateTimeStamp.length -3]  doubleValue]] ;
    NSString *updateString = [updateDate description];
    _updateTimeLabel.text = [NSString stringWithFormat:@"%@最后编辑", [updateString substringToIndex:11]];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

- (void)dealloc {
    [_titleLabel release];
    [_updateTimeLabel release];
    [super dealloc];
}
@end
